
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#include "common/person.h"

std::vector<std::string> append_name_if(std::vector<std::string> prev_collected, const person_t& person)
{
    if (person.gender() == person_t::female) {
        prev_collected.push_back(person.name());
    }
    return prev_collected;
}

int main()
{
    std::vector<person_t> people {
        { "David", person_t::male },
        { "Jane", person_t::female },
        { "Martha", person_t::female },
        { "Peter", person_t::male },
        { "Rose", person_t::female },
        { "Tom", person_t::male }
    };

    for (auto& p : people) {
        p.print(std::cout, person_t::full_name);
    }
    auto res = std::accumulate(people.cbegin(), people.cend(), std::vector<std::string> {}, append_name_if);

    std::cout << "------------------------------------" << std::endl;
    for (auto& name : res) {
        std::cout << name << " ";
    }
    std::cout << std::endl;

    return 0;
}